<?php

namespace App\Service\UserCenter\v1_2_7;

use App\Constants\ErrorCode;
use App\Model\UserSetting;
use App\Service\BaseService;

/**
 * 设置显示
 */
class SetMyShowService extends BaseService
{
    public function handle()
    {
        $showtype = $this->request->input('show_type', '');
        $op = $this->request->input('op', 1);
        if (!in_array($showtype, ['gift', 'location', 'charm'])) {
            return $this->setError(ErrorCode::PARAMETER_ERROR, '参数错误');
        }
        if ($op == 1) UserSetting::permitShow($this->userId, $showtype);
        else UserSetting::forbidShow($this->userId, $showtype);
        return ['result' => 1, 'tip' => '保存成功，别人浏览你的主页将不会显示该内容！'];
    }
}
